home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / c / lzw4c13.zip / LZW4C.DOC < prev    next >
Text File  |  1993-09-09  |  39KB  |  1,081 lines

  1.  
  2.  
  3.                           LZW Data Compression Library
  4.  
  5.                                 For the C Language
  6.  
  7.  
  8.                                     (LZW4C)
  9.  
  10.  
  11.  
  12.                                  USERS MANUAL
  13.  
  14.  
  15.  
  16.  
  17.  
  18.                                   Version 1.3
  19.  
  20.                                  Sept 10, 1993
  21.  
  22.  
  23.  
  24.  
  25.                         This software is provided as-is.
  26.                  There are no warranties, expressed or implied.
  27.  
  28.  
  29.  
  30.  
  31.                               Copyright (C) 1993
  32.                               All rights reserved
  33.  
  34.  
  35.  
  36.                               MarshallSoft Computing, Inc.
  37.                               Post Office Box 4543
  38.                               Huntsville AL 35815
  39.  
  40.                               205-881-4630 Voice / FAX
  41.                               205-880-9748 Support BBS
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.         LZW4C Users Manual                                     Page 1
  61.                               C O N T E N T S
  62.  
  63.  
  64.  
  65.  
  66.  
  67.          Chapter                                                   Page
  68.  
  69.          1.0 Introduction..............................................3
  70.              1.1 Distribution Files....................................3
  71.              1.2 Compiling the Library.................................4
  72.              1.3 User Support..........................................4
  73.              1.4 Installation..........................................5
  74.          2.0 The LZW Algorithm.........................................6
  75.              2.1 LZW Compression.......................................6
  76.              2.2 LZW Expansion.........................................7
  77.              2.3 LZW Implementation....................................7
  78.          3.0 Example Programs..........................................8
  79.              3.1 COMPRESS..............................................8
  80.              3.2 EXPAND................................................8
  81.              3.3 TEST_LZW..............................................9
  82.              3.4 MK_ARC................................................9
  83.              3.5 UN_ARC................................................9
  84.              3.6 SEE_ARC...............................................9
  85.          4.0 Reader & Writer Functions................................10
  86.          5.0 Library Functions........................................11
  87.              5.1 InitLZW..............................................11
  88.              5.2 TermLZW..............................................11
  89.              5.3 Compress.............................................12
  90.              5.4 Expand...............................................12
  91.          6.0 Error Codes..............................................13
  92.              6.1 EXPANSION_ERROR......................................13
  93.              6.2 CANNOT_ALLOCATE......................................13
  94.              6.3 INTERNAL_ERROR.......................................13
  95.              6.4 NOT_READY............................................13
  96.              6.5 BAD_BITCODE..........................................13
  97.          7.0 Legal Issues.............................................14
  98.              7.1 Registration.........................................14
  99.              7.2 Referral Plan........................................14
  100.              7.3 License..............................................15
  101.              7.4 Warranty.............................................15
  102.          8.0 Revision History.........................................16
  103.          9.0 Other MarshallSoft Computing Products for C..............17
  104.              9.1 The Personal Communications Library for C............17
  105.              9.2 The Personal Protocol Library for C..................17
  106.              9.3 The EMS Expanded Memory Library for C................18
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.         LZW4C Users Manual                                     Page 2
  121.          1.0 Introduction
  122.  
  123.  
  124.          LZW4C  consists  of a variable code size implementation of the LZW
  125.          (Lempel-Ziv-Welch) algorithm  for  compressing  and  decompressing
  126.          data.   LZW does particularly well on text files, achieving better
  127.          than a 50 % compression ratio for many files.
  128.  
  129.          The LZW algorithm is considered to be  one  of  the  best  general
  130.          purpose  algorithms  available  today.   The new high speed modems
  131.          that employ on-the-fly data compression (such as  MNP  5.0  &  the
  132.          V.42 bis international standard) use the LZW algorithm, as well as
  133.          such well known utility programs such as PKZIP.
  134.  
  135.          The  LZW4C  library  is  designed  to be used in a wide variety of
  136.          situations. Some of the possible uses include:
  137.  
  138.          1) Compression and expanding files on disk.
  139.          2) Compressing files "on the fly" before  sending  over  a  modem,
  140.             and then expanding on the receiving end.
  141.          3) Compression of data files used by your application program such
  142.             as help files, graphics screens, etc. The compressed data files
  143.             are then expanded as they are loaded by the application.
  144.  
  145.  
  146.          1.1 Distribution Files
  147.  
  148.          The distribution files are as follows:
  149.  
  150.           1) LZW4C_C.LIB -- COMPACT model library.
  151.           2) LZW4C_L.LIB -- LARGE model library.
  152.           3) LZW4C_L.MIX -- LARGE model library (MIX only).
  153.           4) LZW4C.DOC   -- This documentation file.
  154.           5) LZW4C.INV   -- Invoice file.
  155.           6) COMPRESS.C  -- Data compression example program.
  156.           7) EXPAND.C    -- Data expansion example program.
  157.           8) LZW4C.H     -- Library prototypes.
  158.           9) TEST_LZW.C  -- LZW test driver program.
  159.          10) MK_ARC.C    -- File archiving program.
  160.          11) UN_ARC.C    -- File un-archiving program.
  161.          12) SEE_ARC.C   -- Program to list archived files.
  162.          13) *._T_       -- Turbo C makefiles.
  163.          14) *._M_       -- Microsoft C makefiles.
  164.          15) X_*.BAT     -- MIX Power C batch file.
  165.          16) RW_IO.C     -- Reader/Writer I/O source file.
  166.          17) RW_IO.H     -- Reader/Writer prototype file.
  167.          18) DIR_IO.C    -- Directory I/O source file.
  168.          19) DIR_IO.H    -- Directory I/O prototype file.
  169.          20) SAYERROR.C  -- Displays text error messages.
  170.  
  171.          Registered users also receive:
  172.  
  173.           1) LZW4C.ASM   -- SOURCE CODE for the LZW4C libraries.
  174.           2) MAKE_C.BAT  -- Batch file to make LZW4C_C.LIB
  175.           3) MAKE_L.BAT  -- Batch file to make LZW4C_L.LIB
  176.           4) MAKE_XL.BAT -- Batch file to make LZW4C_L.MIX
  177.  
  178.  
  179.  
  180.         LZW4C Users Manual                                     Page 3
  181.          1.2 Compiling the Library
  182.  
  183.  
  184.          LZW4C  requires  rather  large  work  buffers  at  run time.  This
  185.          requires "far" data pointers which in turn  means  that  you  must
  186.          compile  using  either  the COMPACT memory model (with "near" code
  187.          pointers) or the LARGE memory model (with "far"  code  addresses).
  188.          There are, therefore, two memory model libraries provided:
  189.  
  190.          lzw4c_c.lib  -- Compact memory model library.
  191.          lzw4c_l.lib  -- Large memory model library.
  192.          lzw4c_l.mix  -- Large memory model library (MIX only).
  193.  
  194.          The registered user can re-compile the source code (source code is
  195.          provided in the registered version only) for the library using one
  196.          of the two provided batch files:
  197.  
  198.          make_c.bat  -- Creates lzw4c_c.lib.
  199.          make_l.bat  -- Creates lzw4c_l.lib.
  200.          make_xl.bat -- Create lzw4c_c.mix.
  201.  
  202.          Using  the  COMPACT memory model will result in a slightly smaller
  203.          and faster executable than using the LARGE memory model.  Be  sure
  204.          to compile all of your code for the correct memory model. Refer to
  205.          your compiler manual for more information on memory models.
  206.  
  207.  
  208.          1.3 User Support
  209.  
  210.          We  want you to be successful in developing your application using
  211.          our libraries! We depend on our customers to let us know what they
  212.          need in a library.  This means we are committed to  providing  the
  213.          best  libraries  that  we  can.   If  you  have any suggestions or
  214.          comments, please write to us or give us a call.
  215.  
  216.          If  you  are having a problem using LZW4C or any of our libraries,
  217.          call (205) 881-4630 between 5 PM  and  9  PM  CST  Monday  through
  218.          Friday.  You can call at other times and leave a message, and call
  219.          back  later during our regular business hours for a reply. You can
  220.          also FAX us at this same number at any time.
  221.  
  222.          You  may  also  call our 24 hour BBS (2400 baud, no parity, 8 data
  223.          bits, 1 stop bit) at any time.  The BBS will  contain  the  latest
  224.          shareware version of LZW4C, messages, and other related files. All
  225.          files  are  in standard ZIP format. You can leave a message on the
  226.          BBS, and we will usually have a reply  ready  for  you  within  24
  227.          hours.   The dedicated telephone number is 205-880-9748.  Set your
  228.          modem for 1200 to 9600 baud, 8 data bits, no parity, one stop bit.
  229.  
  230.          The  MarshallSoft  Computing,  Inc.   newsletter  "Comm  Talk"  is
  231.          published quarterly.  It discusses various communications problems
  232.          and solutions using PCL4C (the communications library) as well  as
  233.          related  information  such as data compression issues.  Registered
  234.          users receive a one year  complimentary  subscription  when  first
  235.          registering  and  for  each  update  purchased.  However, overseas
  236.          customers who  want  the  newsletter  must  pay  $5  for  postage.
  237.          Additional  one year subscriptions are $15 plus $5 for postage for
  238.          overseas customers.
  239.  
  240.         LZW4C Users Manual                                     Page 4
  241.          1.4 Installation
  242.  
  243.  
  244.          (1)  Microsoft C, Borland & Turbo C, and MIX Power C compilers are
  245.          supported. However, the code should work with most any C compiler.
  246.          Before installation of LZW4C, your C compiler  should  already  be
  247.          installed  on your system and tested. If you are not familiar with
  248.          makefiles, refer to your compiler manual. If  you  are  using  the
  249.          interactive environment for Quick C or Turbo C, be sure to compile
  250.          with the memory model corresponding to the LZW4C library used.
  251.  
  252.          (2) Make a backup  copy  of  your  distribution  disk.   Put  your
  253.          original distribution disk in a safe place.
  254.  
  255.          (3)  Create  a  work  directory  on  your work disk (normally your
  256.          harddisk). For example, to create a work directory named LZW4C, we
  257.          first log onto the work disk and then type:
  258.  
  259.                                MKDIR LZW4C
  260.  
  261.          (4)  Copy  all the files from your backup copy of the distribution
  262.          disk to your work directory.  For example, to  copy  from  the  A:
  263.          drive to your work directory, we type:
  264.  
  265.                               CD LZW4C
  266.                               COPY A:*.*
  267.  
  268.          (5) Compile COMPRESS.C, EXPAND.C, TEST_LZW.C  and  link  with  the
  269.          appropriate LZW4C library (they use the COMPACT library except for
  270.          MIX Power C). For example, to make COMPRESS.EXE:
  271.  
  272.              a) Borland Turbo C: Type
  273.  
  274.                   MAKE -fCOMPRESS._T_
  275.  
  276.              b) Microsoft C: Type
  277.  
  278.                   MAKE COMPRESS._M_
  279.  
  280.              c) MIX Power C: Type (LARGE model only)
  281.  
  282.                   X_COMPRESS
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.         LZW4C Users Manual                                     Page 5
  301.          2.0 The LZW Algorithm
  302.  
  303.  
  304.          The following discussion of the LZW algorithm is meant to  provide
  305.          a  high  level  overview  of  LZW.  For those interested in a more
  306.          detailed explanation, several good books  are  available  on  data
  307.          compression.
  308.  
  309.          The original research papers on what is now called LZW compression
  310.          are:
  311.  
  312.              J. ZIV and A. Lempel,
  313.              "A Universal Algorithm for Sequential Data Compression",
  314.              IEEE Transactions on Information Theory, May 1977.
  315.  
  316.              Terry Welch,
  317.              "A Technique for High-Performance Data Compression",
  318.               Computer, June 1984.
  319.  
  320.  
  321.          2.1 LZW Compression
  322.  
  323.  
  324.          The  LZW  compressor  reads  8-bit  bytes  from  a data source and
  325.          outputs N-bit codes each of which identifies a previously  defined
  326.          string.   The  value  of  N starts at 9. Thus, codes 0 through 255
  327.          (0xff) correspond with the standard character set, while codes 256
  328.          (0x100) through 511 (0x1ff) correspond to a byte-byte  pair  or  a
  329.          code-byte pair in the code table. After code 511 is output, 10 bit
  330.          codes  are used. This is repeated until the maximum number of bits
  331.          per code is reached. LZW4C can use a maximum value of 12, 13 or 14
  332.          bits per code. The recommended value is 14.
  333.  
  334.          The LZW compressor builds a code table as it compresses data.  The
  335.          code table consists of previously encountered strings.
  336.  
  337.          The basic LZW compression algorithm is as follows:
  338.  
  339.              STRING = get first input byte
  340.              while there is more input data
  341.                {BYTE = get next input byte
  342.                 if STRING+BYTE is in code table
  343.                    STRING=STRING+BYTE
  344.                 else
  345.                   {output code for STRING
  346.                    add STRING+BYTE to code table
  347.                    STRING = BYTE
  348.                   }
  349.               }
  350.              output the code for STRING
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.         LZW4C Users Manual                                     Page 6
  361.          2.2 LZW Expansion
  362.  
  363.  
  364.          The LZW expansion routine reads the N-bit codes previously created
  365.          by  the  LZW  compressor  and  reconstructs  the  code  table  (as
  366.          previously constructed by the compressor) as it is outputing 8-bit
  367.          bytes.  A code corresponds to a single byte (the first  256  codes
  368.          from 0x00 through 0xff), or a byte-byte pair in the code table, or
  369.          a  code-byte  pair  in the code table. In the later case, the code
  370.          part of the code-byte pair refers to another defined code pair  in
  371.          the  table.   As  each  code is read in, it is located in the code
  372.          table and the corresponding 8-bit bytes are  output.   This  means
  373.          that  codes  must be defined before they are needed for expansion.
  374.          Unlike  older  dictionary  based  compression  schemes,  the  code
  375.          dictionary  produced by the compressor routine does not have to be
  376.          provided to the expansion routine.
  377.  
  378.          The basic LZW de-compression algorithm is as follows:
  379.  
  380.              OLDCODE = input first code
  381.              output OLDCODE
  382.              while there is more input data
  383.                {NEWCODE = get next input code
  384.                 STRING = translation of NEWCODE
  385.                 output STRING
  386.                 BYTE = 1st byte of STRING
  387.                 add OLDCODE+BYTE to the code table
  388.                 OLDCODE = NEWCODE
  389.                }
  390.  
  391.          2.3 Implementation
  392.  
  393.  
  394.          The LZW4C library is written in assembly language.  Any  Microsoft
  395.          or  compatible assembler will assemble it. The decision to program
  396.          LZW4C in assembler was made in order to get the  absolute  maximum
  397.          performance  possible.  Although  optimized  C is very good, it is
  398.          still bigger and slower than hand optimized assembler.
  399.  
  400.          The LZW algorithm requires more temporary working data space  than
  401.          is  available  in  the  SMALL or MEDIUM memory models.  Therefore,
  402.          there are no SMALL or MEDIUM memory model libraries provided,  but
  403.          there  are  COMPACT  (lzw4c_c.lib)  and LARGE (lzw4c_l.lib) memory
  404.          model libraries.
  405.  
  406.          Use the COMPACT memory model when your code will fit into 64KB  or
  407.          less, otherwise you must use the LARGE memory model. Refer to your
  408.          compiler manual for a complete discussion of memory models.
  409.  
  410.          Using a maximum of 12 bits per code (see the InitLZW()  function),
  411.          25105  bytes  are  allocated for table space.  This value jumps to
  412.          45145 bytes when using 13 bytes and  90205  bytes  when  using  14
  413.          bits. The best compression is given using 14 bits per code.
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.         LZW4C Users Manual                                     Page 7
  421.          3.0 Example Programs
  422.  
  423.  
  424.          Five example programs are provided.  Each example  program  should
  425.          be  compiled  with  the provided makefile.  These example programs
  426.          are meant to demonstrate various ways in which the LZW compression
  427.          library can be used.
  428.  
  429.          If you are using an integrated  compiler  environment  instead  of
  430.          makefiles,  notice  that each program is compiled with the COMPACT
  431.          memory model.
  432.  
  433.  
  434.          3.1 COMPRESS
  435.  
  436.  
  437.          The  program  COMPRESS  is  provided  as  both  a  standalone  LZW
  438.          compression  program,  and  as  an example of how to use the LZW4C
  439.          library to compress a file. In order to run COMPRESS, type
  440.  
  441.              COMPRESS <infile> <outfile>
  442.  
  443.          For example, to compress LZW4C.DOC to LZW4C.LZW, type
  444.  
  445.              COMPRESS LZW4C.DOC LZW4C.LZW
  446.  
  447.  
  448.          3.2 EXPAND
  449.  
  450.  
  451.          The  program  EXPAND  is  provided  as  both  a   standalone   LZW
  452.          de-compression  program, and as an example of how to use the LZW4C
  453.          library to de-compress a file. In order to run EXPAND, type
  454.  
  455.              EXPAND <infile> <outfile>
  456.  
  457.          For example, to de-compress LZW4C.LZW to LZW4C.DOC, type
  458.  
  459.              COMPRESS LZW4C.LZW LZW4C.DOC
  460.  
  461.          Of course, you can only decompress a file that has been compressed
  462.          with COMPRESS.
  463.  
  464.  
  465.  
  466.  
  467.  
  468.  
  469.  
  470.  
  471.  
  472.  
  473.  
  474.  
  475.  
  476.  
  477.  
  478.  
  479.  
  480.         LZW4C Users Manual                                     Page 8
  481.          3.3 TEST_LZW
  482.  
  483.  
  484.          The program TEST_LZW is used to compress, expand, and  verify  one
  485.          or  more  files. It's purpose is for you to test the LZW4C library
  486.          on your own files.  Your files are never modified.   However,  you
  487.          can  NOT  specify  a file named "XXX.XXX" or "YYY.YYY" since these
  488.          files are work files used by  COMPRESS  and  EXPAND.   Compression
  489.          ratios  (  compressed_size  / original_size ) are printed for each
  490.          file compressed. For example, to test all files ending with a  *.C
  491.          extension, type:
  492.  
  493.              TEST_LZW *.C
  494.  
  495.          After compiling TEST_LZW, run it  against  a  large  directory  of
  496.          files as a test of the library. TEST_LZW can also be  run  with  a
  497.          maximum  of  12  or  13  bits per code rather than the standard 14
  498.          bits (the preferred value). To test all files ending  with  a  *.C
  499.          extension using a maximum of 13 bits per code, type:
  500.  
  501.              TEST_LZW *.C 13
  502.  
  503.  
  504.          3.4 MK_ARC
  505.  
  506.  
  507.          The program MK_ARC is used to create an archive file. For example,
  508.          to  create  an  archive named C.ARF consisting of all files ending
  509.          with the extension '.C', type:
  510.  
  511.              MK_ARC *.C C.ARF
  512.  
  513.  
  514.          3.5 UN_ARC
  515.  
  516.  
  517.          The program UN_ARC is used to un-archive  the  files  archived  by
  518.          MK_ARC. For example, to un-archive C.ARF, type:
  519.  
  520.              UN_ARC C.ARF
  521.  
  522.          Note  that  the  UN_ARC  program  can be modified to provide for a
  523.          customized product installation program.
  524.  
  525.          3.6 SEE_ARC
  526.  
  527.          The  program SEE_ARC is used to list the files in any archive file
  528.          created with MK_ARC. For example, to see the files in C.ARF:
  529.  
  530.              SEE_ARC C.ARF
  531.  
  532.          All example code should be compiled using the COMPACT memory model
  533.          (FAR data pointers, NEAR code pointers). You may  create  a  LARGE
  534.          memory model version of the above five programs by re-compiling as
  535.          LARGE memory model programs.
  536.  
  537.  
  538.  
  539.  
  540.         LZW4C Users Manual                                     Page 9
  541.          4.0 Reader & Writer Functions
  542.  
  543.  
  544.          Both  the  compression and expansion routines in the LZW4C library
  545.          use Reader and Writer functions supplied by  the  library  caller.
  546.          They are provided as a means of giving the caller complete control
  547.          over  the  source  and  destination  of  the  data  stream  during
  548.          compression and expansion.
  549.  
  550.          A reader function is not limited to reading from disk. It may read
  551.          from  any  data source as long as it returns a -1 when there is no
  552.          more data to be read. Similiarly, a writer function may  write  to
  553.          any data sink.
  554.  
  555.          A simple example of suitable reader and writer functions which can
  556.          be used to compress and expand files on disk are as follows:
  557.  
  558.              int Reader()
  559.              {
  560.               return(fgetc(FileInp));
  561.              }
  562.  
  563.              int Writer(Byte)
  564.              char Byte;
  565.              {
  566.               return(fputc(Byte,FileOut));
  567.              }
  568.  
  569.          where   FileInp   correspond  to  the  input  stream  and  FileOut
  570.          corresponds to the output stream:
  571.  
  572.              FILE *FileInp;
  573.              FILE *FileOut;
  574.  
  575.              FileInp = fopen(<input_file_name>,"rb");
  576.              FileOut = fopen(<output_file_name>,"wb");
  577.  
  578.          Note that the Reader returns a -1 for an end  of  data  condition.
  579.          Data is returned as an integer with the high byte set to 0.  Thus,
  580.          the  only  integers  can  can  be  returned  by  the Reader are -1
  581.          (0xffff) and 0 (0x0000) to 255 (0x00ff).
  582.  
  583.          If you remove data from a character buffer, be sure  to  zero  out
  584.          the  high  order byte (AND with 0x00ff) unless you are returning a
  585.          -1 (EOF).  For an example,  examine  the  code  for  the  Reader()
  586.          function in RW_IO.C.
  587.  
  588.  
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.         LZW4C Users Manual                                     Page 10
  601.          5.0 Library Functions
  602.  
  603.  
  604.          There are four functions in the LZW4C library as follows:
  605.  
  606.  
  607.          5.1 InitLZW
  608.  
  609.  
  610.          Function:     Initialize library
  611.  
  612.          Prototype:    int InitLZW(Alloc,BitCode)
  613.                        void (*Alloc)(); /* pointer to allocate function */
  614.                        int BitCode;     /* maximum bits per code */
  615.  
  616.          Description:  The  InitLZW  function  is  used  to initialize  the
  617.                        library.  The first argument is the function name of
  618.                        a user supplied memory allocation function.  Use the
  619.                        standard C library function malloc() unless you wish
  620.                        to use your own memory management function.
  621.  
  622.                        The second argument <BitCode> is the maximum  number
  623.                        of  bits  used  per code in the compression process.
  624.                        Legal values are  12,  13,  and  14  (the  preferred
  625.                        value).  Smaller values will use less memory but not
  626.                        compress as tightly.
  627.  
  628.          Returns:      -2 : (CANNOT_ALLOCATE) -- if unable to allocate.
  629.                        -5 : (BAD_BITCODE) -- BitCode not 12, 13, or 14.
  630.                         0 : (AOK) -- no error.
  631.  
  632.          Example:      /* initialize LZW4C */
  633.                        char *malloc();
  634.                        InitLZW(malloc,14);
  635.  
  636.  
  637.          5.2 TermLZW
  638.  
  639.  
  640.          Function:     Terminate library
  641.  
  642.          Prototype:    int TermLZW(Free)
  643.                        void (*Free)();  /* pointer to free function */
  644.  
  645.          Description:  The  TermLZW  function  is  used  to  terminate  the
  646.                        library after all processing is  done.   The  single
  647.                        argument  is  the  function  name of a user supplied
  648.                        memory de-allocation function.  This is primarily  a
  649.                        way   to   free memory allocated by InitLZW. Use the
  650.                        standard C library function free() unless  you  wish
  651.                        to use your own memory management free function.
  652.  
  653.          Returns:      0 : (AOK) -- no error.
  654.  
  655.          Example:      /* terminate LZW4C */
  656.  
  657.                        TermLZW(free);
  658.  
  659.  
  660.         LZW4C Users Manual                                     Page 11
  661.          5.3 Compress
  662.  
  663.  
  664.          Function:     Compresses a data set.
  665.  
  666.          Prototype:    int Compress(Reader,Writer)
  667.                        int (*Reader)();     /* pointer to Reader() */
  668.                        int (*Writer)();     /* pointer to Writer() */
  669.  
  670.          Description:  The  Compress  function  is used to compress  a data
  671.                        set.  The Reader function always  returns  the  next
  672.                        input  byte.  The  Writer function consumes the next
  673.                        output byte. Refer to the section  on  Reader/Writer
  674.                        I/O.
  675.  
  676.          Returns:      -4 : (NOT_READY) -- Didn't call InitLZW() first.
  677.                         0 : (AOK) -- No error.
  678.  
  679.          Example:      /* compress a file */
  680.                        FILE *FileInp, *FileOut;
  681.                        FileInp = fopen("LZW4C.DOC","rb");
  682.                        FileOut = fopen("LZW4C.LZW","wb");
  683.                        Compress(Reader,Writer);
  684.  
  685.                        int Reader()
  686.                        {return(fgetc(FilePtr));}
  687.  
  688.                        int Writer(Byte)
  689.                        int Byte;
  690.                        {return(fputc(Byte,FilePtr));}
  691.  
  692.  
  693.          5.4 Expand
  694.  
  695.  
  696.          Function:     Expands a file.
  697.  
  698.          Prototype:    int Expand(Reader,Writer)
  699.                        int (*Reader)();     /* pointer to Reader() */
  700.                        int (*Writer)();     /* pointer to Writer() */
  701.  
  702.          Description:  The  Expand  function is used to de-compress  a file
  703.                        previously compressed with  the  Compress  function.
  704.                        The  Reader  function  always returns the next input
  705.                        byte.  The Writer function consumes the next  output
  706.                        byte.  Refer  to  the  section on Reader/Writer I/O.
  707.  
  708.          Returns:      -1 : (EXPANSION_ERROR)  -- File not compressed by
  709.                              the compress function.
  710.                         0 : (AOK) -- No error.
  711.  
  712.          Example:      /*  de-compress a file */
  713.                        FILE *FileInp, *FileOut;
  714.                        FileInp = fopen("LZW4C.DOC","rb");
  715.                        FileOut = fopen("LZW4C.LZW","wb");
  716.                        Expand(Reader,Writer);
  717.  
  718.  
  719.  
  720.         LZW4C Users Manual                                     Page 12
  721.          6.0 Error Codes
  722.  
  723.  
  724.          Be  sure and check the return codes from each LZW4C function call.
  725.          There are only 5 error codes returned by the LZW4C  library  other
  726.          than  0  (no  error). All error codes are negative numbers.  Their
  727.          numerical values are in the  LZW4C.H  file.  Each  error  code  is
  728.          returned by a library function as follows:
  729.  
  730.          ****************************************************************
  731.          *    Error Name    *  IntLZW  *  TermLZW * Compress *  Expand  *
  732.          ****************************************************************
  733.          * EXPANSION_ERROR  *    No    *    No    *    No    *    Yes   *
  734.          * CANNOT_ALLOCATE  *    Yes   *    No    *    No    *    No    *
  735.          * INTERNAL_ERROR   *    Yes   *    No    *    No    *    No    *
  736.          * NOT_READY        *    No    *    No    *    Yes   *    Yes   *
  737.          * BAD_BITCODE      *    Yes   *    No    *    No    *    No    *
  738.          ****************************************************************
  739.  
  740.  
  741.          6.1 EXPANSION_ERROR
  742.  
  743.          An EXPANSION_ERROR error is returned only by the Expand()  library
  744.          function. It is caused by attempting to expand a file that was not
  745.          compressed   by  the  Compress()  function.  Note,  however,  that
  746.          Expand() may expand a file that was not compressed  by  Compress()
  747.          without returning an EXPANSION error.
  748.  
  749.          6.2 CANNOT_ALLOCATE
  750.  
  751.          A  CANNOT_ALLOCATE error is returned only by the InitLZW() library
  752.          function.  It is  caused  when  the  Alloc()  function  passed  to
  753.          InitLZW()  returns  a  NULL  pointer,  indicating  that  it cannot
  754.          allocate sufficient memory.
  755.  
  756.          6.3 INTERNAL_ERROR
  757.  
  758.          An INTERNAL_ERROR error is returned only by the InitLZW()  library
  759.          function  and  only  in  the  shareware  version.  It is caused by
  760.          modification of the Shareware screen. You should  never  get  this
  761.          error.
  762.  
  763.          6.4 NOT_READY
  764.  
  765.          A NOT_READY error is  returned  by  the  Compress()  and  Expand()
  766.          library  functions. It is caused by calling Compress() or Expand()
  767.          without first calling InitLZW().
  768.  
  769.          6.5 BAD_BITCODE
  770.  
  771.          A  BAD_BITCODE  error  is returned from InitLZW() when specifing a
  772.          BitCode of other than 12, 13, or 14.
  773.  
  774.  
  775.  
  776.  
  777.  
  778.  
  779.  
  780.         LZW4C Users Manual                                     Page 13
  781.          7.0 Legal Issues
  782.  
  783.          7.1 Registration
  784.  
  785.          If you wish to register the LZW4C Library, please send $35 plus $3
  786.          S&H ($6 outside of North America) to:
  787.  
  788.                   MarshallSoft Computing, Inc.
  789.                   Post Office Box  4543
  790.                   Huntsville AL 35815
  791.  
  792.          We accept  American  Express  (account  number,  expiration  date,
  793.          exact  name  on  your  card,  and  complete  AmEx  billing address
  794.          required), checks in US dollars  drawn  on  a  US  bank,  purchase
  795.          orders  (POs)  from  recognized  US schools and companies listed in
  796.          Dun &  Bradstreet,  and  COD  (street  address  and  phone  number
  797.          required)  within  the USA (plus a $3 COD charge).  Print the file
  798.          PCL4C.INV if an invoice  is  needed.
  799.  
  800.          You  can  also  order LZW4C from The Public Software Library (PSL)
  801.          with your MC, Visa, AmEx, or Discover card by calling 800-242-4PSL
  802.          (from overseas: 713-524-6394) or by  FAX  at  713-524-6398  or  by
  803.          CompuServe  at  [71355,470].  THESE NUMBERS ARE FOR ORDERING ONLY.
  804.          The product number for LZW4C is 10910.
  805.  
  806.          If  you  wish  to  update from an older version of LZW4C, send $15
  807.          plus  $3  S&H  ($6 outside  of  North  America).  Updates  must be
  808.          ordered directly from MarshallSoft Computing.
  809.  
  810.          The registered package includes:
  811.  
  812.          o  Small, medium, compact & large LZW4C libs w/o shareware screen.
  813.          o  Assembler source code for the library.
  814.          o  Laser printed Users Manual.
  815.          o  Telephone / FAX / BBS  support for one year.
  816.  
  817.          Print  the  file LZW4C.INV if an invoice is needed. The registered
  818.          user will receive the latest version of LZW4C shipped by  two  day
  819.          priority  mail  (packet  airmail  overseas).   A 5.25" diskette is
  820.          provided unless a 3.5" diskette is requested.
  821.  
  822.  
  823.          6.2 Referral Program
  824.  
  825.  
  826.          The  registered  user  will  receive  a $5 certificate towards any
  827.          MarshallSoft  Computing  product  by  referring  a  new   customer
  828.          (someone  who  has  never registered anything with us) paying full
  829.          price ($55).  The new customer must identify you at the  time  the
  830.          order is placed.  You will be mailed a $5 certificate when the new
  831.          registration is paid.
  832.  
  833.  
  834.  
  835.  
  836.  
  837.  
  838.  
  839.  
  840.         LZW4C Users Manual                                     Page 14
  841.          7.2 License
  842.  
  843.  
  844.          MarshallSoft  Computing,  Inc. grants the registered user of LZW4C
  845.          the right to use  the  LZW4C  library  (in  object  form)  in  the
  846.          development   of  any  software  product  without  any  royalties.
  847.          However,  the  source  code  for  the   library   (LZW4C.ASM)   is
  848.          copyrighted  by  MarshallSoft  Computing  Inc.,  and  may  not  be
  849.          released in whole or in part.
  850.  
  851.  
  852.          7.3 Warranty
  853.  
  854.  
  855.          MARSHALLSOFT COMPUTING, INC. DISCLAIMS ALL WARRANTIES RELATING  TO
  856.          THIS  SOFTWARE,  WHETHER  EXPRESSED  OR IMPLIED, INCLUDING BUT NOT
  857.          LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY  AND  FITNESS
  858.          FOR  A  PARTICULAR  PURPOSE, AND ALL SUCH WARRANTIES ARE EXPRESSLY
  859.          AND SPECIFICALLY DISCLAIMED. NEITHER MARSHALLSOFT COMPUTING,  INC.
  860.          NOR ANYONE ELSE WHO HAS BEEN INVOLVED IN THE CREATION, PRODUCTION,
  861.          OR  DELIVERY  OF  THIS  SOFTWARE SHALL BE LIABLE FOR ANY INDIRECT,
  862.  
  863.          CONSEQUENTIAL, OR INCIDENTAL DAMAGES ARISING OUT  OF  THE  USE  OR
  864.          INABILITY  TO  USE  SUCH  SOFTWARE EVEN IF MARSHALLSOFT COMPUTING,
  865.          INC.  HAS BEEN ADVISED OF  THE  POSSIBILITY  OF  SUCH  DAMAGES  OR
  866.          CLAIMS. IN NO EVENT SHALL MARSHALLSOFT COMPUTING, INC.'S LIABILITY
  867.          FOR ANY SUCH DAMAGES EVER EXCEED THE PRICE PAID FOR THE LICENSE TO
  868.          USE  THE SOFTWARE, REGARDLESS OF THE FORM OF THE CLAIM. THE PERSON
  869.          USING  THE  SOFTWARE  BEARS  ALL  RISK  AS  TO  THE  QUALITY   AND
  870.          PERFORMANCE OF THE SOFTWARE.
  871.  
  872.          Some  states  do not allow the exclusion of the limit of liability
  873.          for consequential or incidental damages, so the  above  limitation
  874.          may not apply to you.
  875.  
  876.          This  agreement  shall  be  governed  by  the laws of the State of
  877.          Alabama and shall inure to the benefit of Marshallsoft  Computing,
  878.          Inc.   and  any successors, administrators, heirs and assigns. Any
  879.          action or proceeding brought by either  party  against  the  other
  880.          arising  out of or related to this agreement shall be brought only
  881.          in a STATE or FEDERAL COURT of competent jurisdiction  located  in
  882.          Madison County, Alabama. The parties hereby consent to in personam
  883.          jurisdiction of said courts.
  884.  
  885.  
  886.  
  887.  
  888.  
  889.  
  890.  
  891.  
  892.  
  893.  
  894.  
  895.  
  896.  
  897.  
  898.  
  899.  
  900.         LZW4C Users Manual                                     Page 15
  901.          8.0 Revision History
  902.  
  903.  
  904.          Version 1.0 -- October 8, 1992
  905.  
  906.          o  Original release.
  907.  
  908.          Version 1.1 -- November 11, 1992
  909.  
  910.          o  Added MK_ARC.C example program.
  911.          o  Added UN_ARC.C example program.
  912.  
  913.          Version 1.2 -- March 1, 1993
  914.  
  915.          o  Added SEE_ARC example program.
  916.          o  Minor speed improvements.
  917.  
  918.          Version 1.3 -- Sept 10, 1993
  919.  
  920.          o  Added BitCode parameter to InitLZW.
  921.          o  LZW4C.H modified for use with both C and C++.
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928.  
  929.  
  930.  
  931.  
  932.  
  933.  
  934.  
  935.  
  936.  
  937.  
  938.  
  939.  
  940.  
  941.  
  942.  
  943.  
  944.  
  945.  
  946.  
  947.  
  948.  
  949.  
  950.  
  951.  
  952.  
  953.  
  954.  
  955.  
  956.  
  957.  
  958.  
  959.  
  960.         LZW4C Users Manual                                     Page 16
  961.          9.0 Other MarshallSoft Computing Products for C
  962.  
  963.  
  964.          Shareware  versions  of  all  MarshallSoft  Computing products are
  965.          available on our user support BBS at 205-880-9748  (1200  to  9600
  966.          baud, 8N1).
  967.  
  968.  
  969.          9.1 The Personal Communications Library for C
  970.  
  971.  
  972.          The Personal Communications Library for the C Language (PCL4C)  is
  973.          an  asynchronous  communications  library designed for experienced
  974.          software  developers  programming  in  C.   Four   compilers   are
  975.          supported:  Microsoft  Optimizing  C,  Microsoft  Quick C, Borland
  976.          Turbo C, and MIX Power  C.   An  IBM  PC/XT/AT  or  compatible  is
  977.          required.  The PCL features:
  978.  
  979.          o SMALL, COMPACT, MEDIUM & LARGE memory models.
  980.          o 36 communications and support functions.
  981.          o Supports the high performance INS16550 UART.
  982.          o Supports the Digiboard PC/4 and PC/8.
  983.          o Supports hardware (RTS/CTS) flow control.
  984.          o Interrupt driven transmitter (optionally) & receiver.
  985.          o Supports 300 baud to 115,200 baud.
  986.          o Supports COM1 through COM4 (through COM10 with Digiboard).
  987.          o Adjustable receive queues from 8 bytes to 32 KB.
  988.          o Control-BREAK error exit.
  989.          o 17 communications error conditions trapped.
  990.          o Allows 4 ports (10 with DigiBoard) to run concurrently.
  991.          o Complete modem control & status.
  992.          o Written in assembly language for small size & high speed.
  993.          o Terminal program featuring XMODEM, YMODEM, & YMODEM-G.
  994.  
  995.          The Personal Communications Library for C (PCL4C) is available for
  996.          $55  plus  $3 S&H ($6 S&H overseas). It may be ordered at the same
  997.          time as the Personal Protocol Library for $65 plus $3.50  S&H  ($7
  998.          overseas).
  999.  
  1000.  
  1001.          9.2 The Personal Protocol Library for C
  1002.  
  1003.  
  1004.          The  Personal  Protocol  Library  (PPL)  consist of a state driven
  1005.          library  which  implements  the  XMODEM,  XMODEM-CRC,   XMODEM-1K,
  1006.          XMODEM-G,  YMODEM,  and  YMODEM-G  file  transfer protocols.  This
  1007.          allows  the  programmer  to  run   multiple   protocol   transfers
  1008.          simultaneously while interacting with the user at the keyboard.
  1009.  
  1010.          The  Personal  Protocol Library for C (PPL4C) is available for $35
  1011.          plus $3 S&H ($6 S&H overseas). Both the Communications library and
  1012.          the Protocol library can be ordered together for $65.
  1013.  
  1014.          The PPL requires the Personal Protocol Library for  C  (PCL4C)  as
  1015.          described above.
  1016.  
  1017.  
  1018.  
  1019.  
  1020.         LZW4C Users Manual                                     Page 17
  1021.          9.3 The EMS Expanded Memory Library
  1022.  
  1023.          The  EMS4C   library   implements   version   3.2   of   the   LIM
  1024.          (Lotus-Intel-Microsoft) specification for expanded memory. It will
  1025.          run with either version 3.2 or 4.0 of the LIM specification.
  1026.  
  1027.          The EMM4C library (included with the EMS4C library) is an expanded
  1028.          memory manager which allows C programmers to allocate and free EMS
  1029.          (expanded)  memory similiar to malloc() and free() in the standard
  1030.          C runtime library. Both EMM4C and EMS4C require that  your  system
  1031.          be  configured  with  expanded (EMS) memory. But, 386 & up systems
  1032.          can use extended memory as expanded memory.
  1033.  
  1034.          The EMS Expanded Memory Library for C is available for $35 plus $3
  1035.          S&H ($6 S&H overseas).
  1036.  
  1037.  
  1038.  
  1039.  
  1040.  
  1041.  
  1042.  
  1043.  
  1044.  
  1045.  
  1046.  
  1047.  
  1048.  
  1049.  
  1050.  
  1051.  
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.  
  1061.  
  1062.  
  1063.  
  1064.  
  1065.  
  1066.  
  1067.  
  1068.  
  1069.  
  1070.  
  1071.  
  1072.  
  1073.  
  1074.  
  1075.  
  1076.  
  1077.  
  1078.  
  1079.  
  1080.         LZW4C Users Manual                                     Page 18
  1081.